@extends('admin.app')
@section('content')
    <link rel="stylesheet" href="/css/icon/iconfont-0130.css">
    <link rel="stylesheet" href="/addons/icheck-1.x/skins/square/green.css">
    <link rel="stylesheet" href="/css/admin/mobileSelect.css">
    @if($skinid == 3)
        <link rel="stylesheet" href="{{assethelp('/css/admin/scale.css?v='.time())}}">
    @elseif($skinid == 1)
        {{--蓝色标准比例样式--}}
        <link rel="stylesheet" href="{{assethelp('/css/theme-blue/admin/scale.css?v='.time())}}">
    @elseif($skinid == 2)
        {{--粉色标准比例样式--}}
        <link rel="stylesheet" href="{{assethelp('/css/theme-pink/admin/scale.css?v='.time())}}">
    @endif
    <script src="/addons/icheck-1.x/icheck.min.js"></script>
    <div class="mian-container">
        <div class="performance-setting">
            <div>
                <div class="weui-cell top-tab">
                    <div class="weui-cell__hd go-back">
                        <p style="/* width: 15px */"></p>
                    </div>
                    <div class="weui-cell__bd centertxt">
                        标准比例设置
                    </div>
                    <div class="weui-cell__ft"></div>
                </div>
            </div>
            <div class="month-now">当前月份：{{$year}}年{{$month}}月</div>
            <div class="new_con">
                <div class="new_con1">
                    <div class="new_con1_tit">比例</div>
                    <div class="new_con1_inp">
                        <input type="text" name="cost" value="@if(!empty($standard)) {{$standard->percent}} @endif" class="admin_free">
                    </div>
                    <div class="precent">%</div>
                </div>
                <div class="new_con2">
                    <div>
                        <div class="new_con2_sure" data-id="">确定</div>
                    </div>
                    <div>
                        <div class="new_con2_del" data-id="">删除</div>
                    </div>
                </div>
            </div>


        </div>

        {!! csrf_field() !!}
        @if($user->getRole()==9)
            @include('sysadmin.admin-caidan')
        @else
            <div class="reful-tabbar">
                <a href="{{url('/user/performance/perf')}}" class="tabbar-item">
                    <p style="line-height: 65px;" class="tabbar-label">返回个人用户界面</p>
                </a>
            </div>

        @endif
    </div>

    <script src="/js/mobileSelect.js"></script>
    <script>
        $(document).ready(function () {
            var time = '{{$start}}';
            // 返回上一页
            $('.go-back').click(function(){
                localStorage.setItem('eee',Date.now());
                window.history.back(-1);
                //history.go(-1);
                // window.location.href=document.referrer;
            });
            $('.kaohe-item').click(function () {
                $('.show-hidden').toggle();
            });
            $('.admin-item').click(function () {
                $('.front-show-hidden').toggle();
            });
            $('.delete-item').click(function () {
                $(this).parent().siblings().find('.icon-shanchu3').toggle();
            })

            $('.sec-name').click(function () {
                $(this).toggleClass('sec-after');
                $(this).siblings('.hidden-div').toggle();

            })

            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });
            //标准比例-点击删除
            $('body').on("click", '.new_con2_del', function () {
                var that = this;
                $.ajax({
                    type: 'post',
                    cache: 'false',
                    url: '/admin/cost/standard-del',
                    data: 'cost=' + 1 +  '&time=' + time,
                    dataType: 'json',
                    success: function (data) {
                        if (data.status == 'success') {
                            $.toast(data.msg, 'text');
                            $(that).parent().parent().parent().find('input[name=cost]').val('');
                        } else {
                            $.toast(data.msg, 'forbidden');
                        }
                    },
                    error: function () {
                        $.toptip('网络异常请重试', 'warning');
                    }
                });

            });


            //标准比例-点击确认
            $('body').on("click", '.new_con2_sure', function () {
                var that = this;
                var cost = $(this).parent().parent().parent().find('input[name=cost]').val();
                $.ajax({
                    type: 'post',
                    cache: 'false',
                    url: '/admin/cost/standard-save',
                    data: 'cost=' + cost +  '&time=' + time ,
                    dataType: 'json',
                    heads : {
                        'content-type' : 'application/x-www-form-urlencoded'
                    },
                    success: function (data) {
                        if (data.status == 'success') {
                            $.toast(data.msg, 'text');
                        } else {
                            $.toast(data.msg, 'forbidden');
                            /*setTimeout(function () {
                             $(that).parent().parent().parent().remove();
                             }, 300);*/
                        }
                    },
                    error: function () {
                        $.toptip('网络异常请重试', 'warning');
                    }
                });
            });
        })
    </script>
@endsection
